package com.example.xuecheng.contentservice.controller;

import com.example.xuecheng.contentservice.service.impl.CourseTeachplanServiceImpl;
import dto.SaveCourseTeachplanDto;
import dto.TeachplanDto;
import exception.ValidationGroups;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *    课程计划管理接口
 * @author xiehaidong
 */
@RestController
@RequestMapping("/teachplan")
@Api(description = "课程计划管理接口")
public class CourseTeachplanController {
    @Autowired
    private CourseTeachplanServiceImpl courseTeachplanService;

    @PostMapping("/")
    @ApiOperation("新增/修改课程计划接口")
    public void createTeacherPlan(@RequestBody@Validated({ValidationGroups.insert.class}) SaveCourseTeachplanDto saveCourseTeachplanDto){
        courseTeachplanService.saveCourseTeachplan(saveCourseTeachplanDto);

    }
    @GetMapping("/{courseId}/tree-nodes")
    @ApiOperation("查询课程计划接口")
    public List<TeachplanDto> getTeacherPlanDto(@PathVariable Long courseId){
        return courseTeachplanService.getTeacherPlanNodes(courseId);

    }
}
